<HTML><HEAD></HEAD><BODY><center><TABLE BORDER=1 RULES=rows cellpadding="5" WIDTH="70%">
<?php

require('globals.php');
require('global_functions.php');
require('logger.php');

$index = 1;
$dealer_id = $_GET['id'];

if (!$dealer_id)
	echo ('This page cannot be directly accessed.');

else {

	$grabber_query = "SELECT * from " . $dealers_table . " WHERE dealer_id=" . $dealer_id;
	$table_query = "SELECT * from " . $tables_table . " WHERE row_a_assignment =" . $dealer_id . " OR row_b_assignment = " . $dealer_id;

	if (!($link = mysql_connect($host, $user, $password)))
		die('Could not connect: ' . mysql_error());

	if (!(mysql_select_db($database)))
		die('Could not select db ' . $database . ': ' . mysql_error());

	$result = mysql_query($grabber_query, $link);
	$tables = mysql_query($table_query, $link);

	if (!$result || !$tables)
		die('Either no matches or the query failed...' . mysql_error());

	$range = mysql_num_fields($result);
	$values = mysql_fetch_row($result);
	$table_range = mysql_num_rows($tables);


?><TR><TD>Table Assignment:</TD><TD>
<?php
	for ($kicker=0; $kicker <= $table_range; $kicker++) {
		$table_result = mysql_fetch_row($tables);
		if ($table_result[1] == $dealer_id)
			echo $table_result[0] . 'A';
		else if ($table_result[2] == $dealer_id)
			echo $table_result[0] . 'B';
		else
			echo $table_result[0] . ' ';
} ?></TD></TR><?
	for ($kicker=0; $kicker <= $range; $kicker++) {
		if ($fieldnames_clean[$kicker][1] != '') {
		?><TR><TD><?=($fieldnames_clean[$kicker][1]) ?>
		</TD><TD><?=SuperSanitizer($fieldnames_clean[$kicker][1], $values[$kicker]) ?>
		</TD></TR><?php
		}
	$index++;
	}

RecordLogEntry($values);

mysql_close($link);

?></TABLE><table width="70%">

<tr><td><center><input type=button value="Edit This Dealer" onClick="location.href='Edit%20Dealer.php?id=<?=$dealer_id ?>'"></A>
				<input type=button value="Return to Search" onClick="history.back()">

</td></tr></table></center><?php } ?>
</BODY></HTML>
